<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use dektrium\user\models\User;
// 获取所有销售
$data = [];

$user = User::find()->all();
if($user){
	$data = \yii\helpers\ArrayHelper::map($user, 'id', function($model){ return $model->profile->name;} );
}
?>
<style type="text/css">
	.field-ordersearch-status {min-width:130px;}
</style>


<div class="order-search">
    <?php $form = ActiveForm::begin([
        'action' => ['confirms', 'product_id'=>$product_id],
        'method' => 'get',
        'layout' => 'inline',
        'options' => ['data-pjax'=>true],
    ]); ?>

    <!-- ?= $form->field($model, 'id') ? -->
    <!-- ?= $form->field($model, 'product_id') ? -->
    <!-- ?= $form->field($model, 'total_sale') ? -->
    <!-- ?= $form->field($model, 'sale_price') ? -->

	<?php if(Yii::$app->user->can('order_all')){ ?>
    <?= $form->field($model, 'member_id')->dropdownList($data, ['prompt'=>'选择销售']) ?>
	<?php } ?>

    <?= $form->field($model, 'code')->textInput(['placeholder' => Yii::t('app.order', 'Code')]) ?>

    <?= $form->field($model, 'source')->dropdownList(Yii::$app->params['order_source'], ['prompt'=>Yii::t('app.order', 'Source')]) ?>

    <!-- ?= $form->field($model, 'status')->dropdownList(Yii::$app->params['order_status'], ['prompt'=>'全部']) ? -->
	<?= $form->field($model, 'status')->widget(kartik\select2\Select2::classname(), [
						'data' => Yii::$app->params['order_status'],
						'options' => [
							'multiple' => true,
							'width' => "150%",
							'placeholder' => '选择订单状态',
						],
						'pluginOptions' => [
							'tags' => true,
							'closeOnSelect' =>  false,  //  选择后不消失
							'maximumInputLength' => 10
						],
					]);
	?>



    <!-- ?= $form->field($model, 'created_at')->widget(kartik\date\DatePicker::classname(),[
                                                'options' => ['placeholder' => Yii::t('app.order', 'Created At')],
                                                'pluginOptions' => [
                                                    'format' => 'yyyy-mm-dd',
                                                    'autoclose'=>true,
                                                    'todayHighlight' => true
                                                ]
                                            ]); ? -->

    <?= $form->field($model, 'username')->textInput(['placeholder' => Yii::t('app.order', 'Username')]) ?>

    <?= $form->field($model, 'company')->textInput(['placeholder' => Yii::t('app.order', 'Company')]) ?>
    <!-- ?= $form->field($model, 'phone')->textInput(['placeholder' => Yii::t('app.order', 'Phone')]) ? -->
	

    <?php // echo $form->field($model, 'price') ?>

    <?php // echo $form->field($model, 'source') ?>

    <?php // echo $form->field($model, 'remark') ?>

    <?php // echo $form->field($model, 'status') ?>


    <?php // echo $form->field($model, 'created_at') ?>

    <?php // echo $form->field($model, 'updated_at') ?>

    <div class="form-group">
        <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
        <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
